home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / godelqc5.zip / MONSTERS.QC < prev    next >
Text File  |  1996-09-17  |  5KB  |  237 lines

  1. /* ALL MONSTERS SHOULD BE 1 0 0 IN COLOR */
  2.  
  3. // name =[framenum,    nexttime, nextthink] {code}
  4. // expands to:
  5. // name ()
  6. // {
  7. //        self.frame=framenum;
  8. //        self.nextthink = time + nexttime;
  9. //        self.think = nextthink
  10. //        <code>
  11. // };
  12.  
  13.  
  14. /*
  15. ================
  16. monster_use
  17.  
  18. Using a monster makes it angry at the current activator
  19. ================
  20. */
  21. void() monster_use =
  22. {
  23.     if (self.enemy)
  24.         return;
  25.     if (self.health <= 0)
  26.         return;
  27.     if (activator.items & IT_INVISIBILITY)
  28.         return;
  29.     if (activator.flags & FL_NOTARGET)
  30.         return;
  31.     if (activator.classname != "player")
  32.         return;
  33.     
  34. // delay reaction so if the monster is teleported, its sound is still
  35. // heard
  36.     self.enemy = activator;
  37.     self.nextthink = time + 0.1;
  38.     self.think = FoundTarget;
  39. };
  40.  
  41. /*
  42. ================
  43. monster_death_use
  44.  
  45. When a mosnter dies, it fires all of its targets with the current
  46. enemy as activator.
  47. ================
  48. */
  49. void() monster_death_use =
  50. {
  51.     local entity     ent, otemp, stemp;
  52.  
  53. // fall to ground
  54.     if (self.flags & FL_FLY)
  55.         self.flags = self.flags - FL_FLY;
  56.     if (self.flags & FL_SWIM)
  57.         self.flags = self.flags - FL_SWIM;
  58.  
  59.     if (!self.target)
  60.         return;
  61.  
  62.     activator = self.enemy;
  63.     SUB_UseTargets ();
  64. };
  65.  
  66.  
  67. //============================================================================
  68.  
  69. void() walkmonster_start_go =
  70. {
  71. local string    stemp;
  72. local entity    etemp;
  73.  
  74.     total_monsters = total_monsters + 1;
  75.     self.origin_z = self.origin_z + 1;    // raise off floor a bit
  76.     droptofloor();
  77.     
  78.     if (!walkmove(0,0))
  79.     {
  80.         dprint ("walkmonster in wall at: ");
  81.         dprint (vtos(self.origin));
  82.         dprint ("\n");
  83.     }
  84.     
  85.     self.takedamage = DAMAGE_AIM;
  86.  
  87.     self.ideal_yaw = self.angles * '0 1 0';
  88.     if (!self.yaw_speed)
  89.         self.yaw_speed = 20;
  90.     self.view_ofs = '0 0 25';
  91.     self.use = monster_use;
  92.     
  93.     self.flags = self.flags | FL_MONSTER;
  94.     
  95.     if (self.target)
  96.     {
  97.         self.goalentity = self.movetarget = find(world, targetname, self.target);
  98.         self.ideal_yaw = vectoyaw(self.goalentity.origin - self.origin);
  99.         if (!self.movetarget)
  100.         {
  101.             dprint ("Monster can't find target at ");
  102.             dprint (vtos(self.origin));
  103.             dprint ("\n");
  104.         }
  105. // this used to be an objerror
  106.         if (self.movetarget.classname == "path_corner")
  107.             self.th_walk ();
  108.         else
  109.             self.pausetime = 99999999;
  110.             self.th_stand ();
  111.     }
  112.     else
  113.     {
  114.         self.pausetime = 99999999;
  115.         self.th_stand ();
  116.     }
  117.  
  118. // spread think times so they don't all happen at same time
  119.     self.nextthink = self.nextthink + random()*0.5;
  120. };
  121.  
  122.  
  123. void() walkmonster_start =
  124. {
  125. // delay drop to floor to make sure all doors have been spawned
  126. // spread think times so they don't all happen at same time
  127.     self.nextthink = self.nextthink + random()*0.5;
  128.     self.think = walkmonster_start_go;
  129. };
  130.  
  131.  
  132.  
  133. void() flymonster_start_go =
  134. {
  135.     self.takedamage = DAMAGE_AIM;
  136.  
  137.     self.ideal_yaw = self.angles * '0 1 0';
  138.     if (!self.yaw_speed)
  139.         self.yaw_speed = 10;
  140.     self.view_ofs = '0 0 25';
  141.     self.use = monster_use;
  142.  
  143.     self.flags = self.flags | FL_FLY;
  144.     self.flags = self.flags | FL_MONSTER;
  145.  
  146.     if (!walkmove(0,0))
  147.     {
  148.         dprint ("flymonster in wall at: ");
  149.         dprint (vtos(self.origin));
  150.         dprint ("\n");
  151.     }
  152.  
  153.     if (self.target)
  154.     {
  155.         self.goalentity = self.movetarget = find(world, targetname, self.target);
  156.         if (!self.movetarget)
  157.         {
  158.             dprint ("Monster can't find target at ");
  159.             dprint (vtos(self.origin));
  160.             dprint ("\n");
  161.         }
  162. // this used to be an objerror
  163.         if (self.movetarget.classname == "path_corner")
  164.             self.th_walk ();
  165.         else
  166.             self.pausetime = 99999999;
  167.             self.th_stand ();
  168.     }
  169.     else
  170.     {
  171.         self.pausetime = 99999999;
  172.         self.th_stand ();
  173.     }
  174. };
  175.  
  176. void() flymonster_start =
  177. {
  178. // spread think times so they don't all happen at same time
  179.     self.nextthink = self.nextthink + random()*0.5;
  180.     self.think = flymonster_start_go;
  181.     total_monsters = total_monsters + 1;
  182. };
  183.  
  184.  
  185. void() swimmonster_start_go =
  186. {
  187.     if (deathmatch!=0 && deathmatch!=3)
  188.     {
  189.         remove(self);
  190.         return;
  191.     }
  192.  
  193.     self.takedamage = DAMAGE_AIM;
  194.     total_monsters = total_monsters + 1;
  195.  
  196.     self.ideal_yaw = self.angles * '0 1 0';
  197.     if (!self.yaw_speed)
  198.         self.yaw_speed = 10;
  199.     self.view_ofs = '0 0 10';
  200.     self.use = monster_use;
  201.     
  202.     self.flags = self.flags | FL_SWIM;
  203.     self.flags = self.flags | FL_MONSTER;
  204.  
  205.     if (self.target)
  206.     {
  207.         self.goalentity = self.movetarget = find(world, targetname, self.target);
  208.         if (!self.movetarget)
  209.         {
  210.             dprint ("Monster can't find target at ");
  211.             dprint (vtos(self.origin));
  212.             dprint ("\n");
  213.         }
  214. // this used to be an objerror
  215.         self.ideal_yaw = vectoyaw(self.goalentity.origin - self.origin);
  216.         self.th_walk ();
  217.     }
  218.     else
  219.     {
  220.         self.pausetime = 99999999;
  221.         self.th_stand ();
  222.     }
  223.  
  224. // spread think times so they don't all happen at same time
  225.     self.nextthink = self.nextthink + random()*0.5;
  226. };
  227.  
  228. void() swimmonster_start =
  229. {
  230. // spread think times so they don't all happen at same time
  231.     self.nextthink = self.nextthink + random()*0.5;
  232.     self.think = swimmonster_start_go;
  233.     total_monsters = total_monsters + 1;
  234. };
  235.  
  236.  
  237.